﻿<!-- ReSharper disable InconsistentNaming -->
<Window x:Class="WSManager.Wpf.Dialogs.EditDefinitions"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:strVar="clr-namespace:StringVariables;assembly=StringVariables"
        Title="EditDefinitions" Height="300" Width="600" x:Name="main">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <ListView x:Name="defList" DataContext="{Binding ElementName=main}" ItemsSource="{Binding Definitions}" Grid.Row="0">
            <ListBox.ItemContainerStyle>
                <Style TargetType="{x:Type ListBoxItem}">
                    <Setter Property="Focusable" Value="False"/>
                </Style>
            </ListBox.ItemContainerStyle>
            <ListView.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" MinWidth="150"/>
                            <ColumnDefinition Width="*" MinWidth="150"/>
                            <ColumnDefinition Width="*" MinWidth="150"/>
                            <ColumnDefinition Width="20" />
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <TextBox Grid.Column="0" Text="{Binding Name,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                        <TextBox Grid.Column="1" Text="{Binding DefaultValue,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                        </TextBox>
                        <ComboBox Grid.Column="2" SelectedItem="{Binding Type, Mode=TwoWay}" ItemsSource="{Binding Source={x:Static strVar:VariableType.List}}">
                            <ComboBox.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding ShortName}" />
                                </DataTemplate>
                            </ComboBox.ItemTemplate>
                            <ComboBox.ItemContainerStyle>
                                <Style>
                                    <Setter Property="Control.ToolTip" Value="{Binding FullName}" />
                                </Style>
                            </ComboBox.ItemContainerStyle>
                        </ComboBox>
                        <CheckBox Grid.Column="3" ToolTip="Allow null" IsChecked="{Binding AllowNull}" />
                        <TextBox Grid.Column="4" Foreground="Red" FontWeight="ExtraBold">
                            <TextBox.Style>
                                <Style>
                                    <Style.Triggers>
                                        <DataTrigger Value="True" Binding="{Binding HasErrors}">
                                            <Setter Property="TextBox.Visibility" Value="Visible"/>
                                        </DataTrigger>
                                        <DataTrigger Value="False" Binding="{Binding HasErrors}">
                                            <Setter Property="TextBox.Visibility" Value="Collapsed"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </TextBox.Style>*</TextBox>
                    </Grid>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
        
        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Button Grid.Column="0" Click="Button_Click" HorizontalAlignment="Left" VerticalAlignment="Top" BorderBrush="{x:Null}" Width="20" Height="20">+</Button>
            <Button Grid.Column="1" x:Name="SaveButton" Click="SaveButton_Click" HorizontalAlignment="Right" Style="{StaticResource bigButton}">Save</Button>
        </Grid>
        
    </Grid>
</Window>
<!-- ReSharper restore InconsistentNaming -->